# Maintainer: Caleb Maclennan <caleb@alerque.com>

pkgbase=lua-vstruct
_rockname=${pkgbase#lua-}
pkgname=("$pkgbase" "lua51-$_rockname" "lua52-$_rockname" "lua53-$_rockname")
pkgver=2.1.1
_rockrel=1
pkgrel=4
pkgdesc='Lua library to manipulate binary data'
arch=(any)
url="https://github.com/ToxicFrog/$_rockname"
license=(MIT)
makedepends=(lua
             lua51
             lua52
             lua53
             luarocks)
_archive="$_rockname-$pkgver"
source=("$_archive.tar.gz::$url/archive/v$pkgver.tar.gz")
sha256sums=('029ae887fc3c59279f378a499741811976d90f9a806569a42f4de80ad349f333')

_package() {
	cd "$_archive"
	luarocks --lua-version="$1" --tree="$pkgdir/usr/" \
		make --deps-mode=none --no-manifest "$_rockname-$pkgver-$_rockrel.rockspec"
    install -Dm0644 -t "$pkgdir/usr/share/licenses/$pkgname/" COPYING
}

package_lua-vstruct() {
	depends=(lua)
	_package 5.4
}

package_lua51-vstruct() {
	depends=(lua51)
	_package 5.1
}

package_lua52-vstruct() {
	depends=(lua52)
	_package 5.2
}

package_lua53-vstruct() {
	depends=(lua53)
	_package 5.3
}
